package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 获取所有套餐信息
     * @return
     */
    @Select("SELECT * from t_setmeal")
    List<Setmeal> getSetMeal();

    /**
     * 根据套餐id查询套餐
     * @param id
     * @return
     */
    @Select("select * from t_setmeal where  id = #{id}")
    Setmeal findById(Integer id);

    /**
     * 获取对应的检查组
     * @param mealId
     * @return
     */
    @Select("select id, code, name, helpCode, sex, remark, attention from t_checkgroup left join t_setmeal_checkgroup tsc on t_checkgroup.id = tsc.checkgroup_id where setmeal_id =  #{mealId}")
    List<CheckGroup> findGroups(Integer mealId);

    /**
     * 通过groupId获取检查项
     * @param groupId
     * @return
     */
    @Select("select id, code, name, sex, age, price, type, attention, remark from t_checkitem left outer join t_checkgroup_checkitem tcc on t_checkitem.id = tcc.checkitem_id where checkgroup_id = #{groupId}")
    List<CheckItem> findItems(Integer groupId);
}
